package com.itheima.web;

import com.itheima.support.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionInvoker {

    @ExceptionHandler
    public Result handleException(Exception ex){
        ex.printStackTrace();
        String _message = null;
        if(ex.getMessage().length() > 200){
            _message = ex.getMessage().substring(0,200);
        }else{
            _message = ex.getMessage();
        }
        return new Result(false,_message);
    }

}
